package han.chensing.latos.common.level.function;

import java.util.List;

public interface ListReference<T>{
    T get(int index);
    int size();

    static <T> ListReference<T> of(List<T> list){
        return new ListReference<>() {
            @Override
            public T get(int index) {
                return list.get(index);
            }

            @Override
            public int size() {
                return list.size();
            }
        };
    }

    static <T> ListReference<T> of(T[] array){
        return new ListReference<>() {
            @Override
            public T get(int index) {
                return array[index];
            }

            @Override
            public int size() {
                return array.length;
            }
        };
    }

    static <T extends Enum<?>> ListReference<String> of(T[] array){
        return new ListReference<>() {
            @Override
            public String get(int index) {
                return array[index].name();
            }
            @Override
            public int size() {
                return array.length;
            }
        };
    }
}
